<?php if (isset($_SESSION['id']) && $_SESSION['id'] == 0): { ?>
<div class="login1">
<a style="color: #009999; margin-left: 50px;">LOGIN</a>
<div  align="center" style="margin-top: 20px;">
    <form method="POST">
        <a style="color: white">Username</a>
            <input type="text" name="username" placeholder="Username or Email">
        <a style="color: white">Password</a>
            <input type="password" name="password" placeholder="password">
        <input type="submit" name="submit" value="submit">
    </form></div></div>
<?php } endif;?>
<?php require_once '../user.php'; ?>
<?php if (isset($_POST['submit'])): ?>
    <?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    $isOk = FALSE;
    $index = -1;
    for ($i = 0; $i < count($users); $i++) {
        if ((strcmp($users[$i]['username'], $username) == 0) &&
                (strcmp($users[$i]['password'], $password) == 0)) {
            $isOk = TRUE;
            $index = $i;
        }
    }
    if ($isOk) {
        $_SESSION["id"] = $users[$index]["id"];
        header("Location:../index3.php");
    } else {
        echo 'lỗi';
    }
    ?>
<?php endif; ?>